package cn.lan.generator.service.impl;

import cn.hutool.core.date.DateUtil;
import cn.lan.generator.manager.EntityRelationManager;
import cn.lan.generator.bean.Connector;
import cn.lan.generator.bean.Module;
import cn.lan.generator.bean.ProjInfo;
import cn.lan.generator.service.CreatePublicFile;
import cn.lan.generator.utils.ConfigUtil;
import cn.lan.generator.utils.Constant;
import cn.lan.generator.utils.FileUtil;
import cn.lan.generator.utils.StringUtil;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

public class CreatePublicFileImpl implements CreatePublicFile {

    @Override
    public void writeFile(ProjInfo projInfo, Connector connector) {
        Map<String, Map<String, String>> fileNames = initFileNames(projInfo, connector);
        String dirPath = FileUtil.getResourceRootDir(projInfo.isDebugModel()) + Constant.TEMPLATE_PATH + "/";
        File file = new File(dirPath);
        writeFile(fileNames, file, projInfo);
    }

    /**
     * 写文件
     *
     * @param fileNames
     * @param sourceFile
     * @param projInfo
     */
    private static void writeFile(Map<String, Map<String, String>> fileNames, File sourceFile, ProjInfo projInfo) {
        if (sourceFile.exists() && sourceFile.isDirectory()) {
            File[] files = sourceFile.listFiles();
            if (files.length > 0) {
                for (int i = 0; i < files.length; i++) {
                    String fiName = files[i].getName();
                    if (files[i].isFile()) {
                        Map<String, String> map = fileNames.get(fiName);
                        if (map != null && map.containsKey("filePackageName")) {
                            String packageName = map.get("filePackageName");
                            String moduleName = map.get("moduleName");

                            String outFilePath = "";
                            if (fiName.indexOf(Constant.FILE_SUFFIX_JAVA) != -1) {
                                if (fiName.indexOf("TemplateApplication.java") != -1) {
                                    String fileName = map.get("applicationFileName") + Constant.FILE_SUFFIX_JAVA;
                                    String suffixPath = packageName.replaceAll("\\.", "\\\\") + "\\" + fileName;
                                    outFilePath = Constant.getFilePath(projInfo, moduleName, Constant.PathType.basePath, suffixPath);
                                } else {
                                    String suffixPath = packageName.replaceAll("\\.", "\\\\") + "\\" + fiName;
                                    outFilePath = Constant.getFilePath(projInfo, moduleName, Constant.PathType.basePath, suffixPath);
                                }
                            } else if (fiName.indexOf("pom_") != -1 && fiName.indexOf(".xml") != -1 || fiName.endsWith(".sh")) {
                                outFilePath = Constant.getFilePath(projInfo, moduleName, null, packageName);
                            } else if (fiName.indexOf("gitignore") != -1) {
                                outFilePath = Constant.getFilePath(projInfo, moduleName, null, packageName);
                            } else if (fiName.indexOf("index.html") != -1) {
                                outFilePath = Constant.getFilePath(projInfo, moduleName, Constant.PathType.resource_templates, packageName);
                            } else if (fiName.indexOf("login.html") != -1) {
                                outFilePath = Constant.getFilePath(projInfo, moduleName, Constant.PathType.resource_templates, packageName);
                            } else if (fiName.indexOf("template_nav.js") != -1) {
                                EntityRelationManager.writeNavJsFile(projInfo, packageName);
                                continue;
                            } else {
                                String suffixPath = packageName.replaceAll("\\/", "\\\\");
                                outFilePath = Constant.getFilePath(projInfo, moduleName, Constant.PathType.resourcePath, suffixPath);
                            }
                            FileUtil.copyFile(projInfo, files[i].getAbsolutePath(), outFilePath, map);
                        }
                    } else if (files[i].isDirectory()) {
                        if (fiName.equals("static") && projInfo.isThymeleaf()) {
                            String srcPath = files[i].getAbsolutePath();
                            String destPath = Constant.getFilePath(projInfo, Module.getModule(projInfo).getWebServer(), Constant.PathType.resourcePath, "");
                            //复制该文件夹下的所有文件
                            FileUtil.copyFile(projInfo, srcPath, destPath);
                        } else {
                            writeFile(fileNames, files[i], projInfo);
                        }
                    }
                }
            }
        }
    }

    /**
     * 初始化 map
     *
     * @param projInfo
     * @param connector
     * @return
     */
    private Map<String, Map<String, String>> initFileNames(final ProjInfo projInfo, final Connector connector) {
        Map<String, Map<String, String>> fileNames = new HashMap<String, Map<String, String>>();
        final String serverBasePackage = ConfigUtil.getServerBasePackage(projInfo.getPackageName());
        final String commonPackage = ConfigUtil.getCommonPackage(projInfo.getPackageName());
        final String commonVoPackage = ConfigUtil.getCommonBeanVoPackage(projInfo.getPackageName());
        final String commonDtoPackage = ConfigUtil.getCommonBeanDtoPackage(projInfo.getPackageName());
        final String mybatisPlusPackage = ConfigUtil.getMybatisPlusPackage(projInfo.getPackageName());
        final String commonConfigPackage = ConfigUtil.getCommonConfigPackage(projInfo.getPackageName());
        final String redisPackage = ConfigUtil.getRedisPackage(projInfo.getPackageName());
        final String tokenBeanPackage = ConfigUtil.getCommonTokenBeanPackage(projInfo.getPackageName());
        final String tokenManagerPackage = ConfigUtil.getTokenManagerPackage(projInfo.getPackageName());
        final String tokenConfigPackage = ConfigUtil.getCommonTokenConfigPackage(projInfo.getPackageName());
        final String controllerPackage = ConfigUtil.getControllerPackage(projInfo.getPackageName());
        final String viewControllerPackage = ConfigUtil.getViewControllerPackage(projInfo.getPackageName());
        final String utilsPackage = ConfigUtil.getCommonUtilsPackage(projInfo.getPackageName());
        final String exceptionPackage = ConfigUtil.getExceptionPackage(projInfo.getPackageName());
        final String validatePackName = ConfigUtil.getValidatePackage(projInfo.getPackageName());
        final String commonBeanPackage = ConfigUtil.getCommonBeanPackage(projInfo.getPackageName());
        final String annotationPackage = ConfigUtil.getAnnotationPackage(projInfo.getPackageName());
        final String filterPackage = ConfigUtil.getFilterPackage(projInfo.getPackageName());
        final String interceptorPackage = ConfigUtil.getInterceptorPackage(projInfo.getPackageName());
        final String serverConfigPath = ConfigUtil.getServerConfigPackage(projInfo.getPackageName());
        final String aspectPackage = ConfigUtil.getAspectPackage(projInfo.getPackageName());
        final String mappingPath = ConfigUtil.getMappingsPackage(projInfo);
        final String mapperPackage = ConfigUtil.getMapperPackage(projInfo);
        final String entityPackage = ConfigUtil.getEntityPackage(projInfo);
        final String enumsPackage = ConfigUtil.getEnumsPackage(projInfo.getPackageName());
        final String modulePackage = ConfigUtil.getModulePackage(projInfo);
        final String accessBaseUrl = projInfo.getAccessBaseUrl();

        fileNames.put("SysLog.java", new HashMap<String, String>() {
            {
                put("filePackageName", annotationPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("SubmitValid.java", new HashMap<String, String>() {
            {
                put("filePackageName", annotationPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("LogAspect.java", new HashMap<String, String>() {
            {
                put("filePackageName", aspectPackage);
                put("annotationPackage", annotationPackage);
                put("commonVoPackage", commonVoPackage);
                put("utilsPackage", utilsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });
        fileNames.put("BaseController.java", new HashMap<String, String>() {
            {
                put("filePackageName", controllerPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("commonBeanPackage", commonBeanPackage);
                put("accessBaseUrl", accessBaseUrl);
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });
        fileNames.put("CorsFilter.java", new HashMap<String, String>() {
            {
                put("filePackageName", filterPackage);
                put("utilPackageName", utilsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });
        fileNames.put("BodyReaderRequestWrapper.java", new HashMap<String, String>() {
            {
                put("filePackageName", utilsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("ManageInterceptor.java", new HashMap<String, String>() {
            {
                put("filePackageName", interceptorPackage);
                put("commonBeanPackage", commonBeanPackage);
                put("utilsPackage", utilsPackage);
                put("enumsPackage", enumsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });
        fileNames.put("ConstantUtil.java", new HashMap<String, String>() {
            {
                put("filePackageName", utilsPackage);
                put("projectName", projInfo.getProjectName());
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("BusinessException.java", new HashMap<String, String>() {
            {
                put("filePackageName", exceptionPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("enumsPackage", enumsPackage);
                put("utilsPackage", utilsPackage);
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("EntityValidation.java", new HashMap<String, String>() {
            {
                put("filePackageName", validatePackName);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("exceptionPackage", exceptionPackage);
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("ValidationType.java", new HashMap<String, String>() {
            {
                put("filePackageName", validatePackName);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("FilterConfig.java", new HashMap<String, String>() {
            {
                put("filePackageName", serverConfigPath);
                put("filterPackage", filterPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });

        fileNames.put("InitialTask.java", new HashMap<String, String>() {
            {
                put("filePackageName", serverConfigPath);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });
        fileNames.put("ExecutorConfig.java", new HashMap<String, String>() {
            {
                put("filePackageName", serverConfigPath);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });
        fileNames.put("startup.sh", new HashMap<String, String>() {
            {
                put("filePackageName", "bin/startup.sh");
                put("webServerModuleName", Module.getModule(projInfo).getWebServer());
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });
        fileNames.put("shutdown.sh", new HashMap<String, String>() {
            {
                put("filePackageName", "bin/shutdown.sh");
                put("webServerModuleName", Module.getModule(projInfo).getWebServer());
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });
        fileNames.put("InterceptorConfig.java", new HashMap<String, String>() {
            {
                put("filePackageName", serverConfigPath);
                put("interceptorPackage", interceptorPackage);
                put("accessBaseUrl", accessBaseUrl);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });
        fileNames.put("GlobalExceptionHandler.java", new HashMap<String, String>() {
            {
                put("filePackageName", interceptorPackage);
                put("controllerPackage", controllerPackage);
                put("commonBeanPackage", commonBeanPackage);
                put("enumsPackage", enumsPackage);
                put("exceptionPackage", exceptionPackage);
                put("utilsPackage", utilsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });
        fileNames.put("FileUtil.java", new HashMap<String, String>() {
            {
                put("filePackageName", utilsPackage);
                put("commonVoPackage", commonVoPackage);
                put("enumsPackage", enumsPackage);
                put("exceptionPackage", exceptionPackage);
                put("utilsPackage", utilsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("JsonConfig.java", new HashMap<String, String>() {
            {
                put("filePackageName", commonConfigPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("DruidConfig.java", new HashMap<String, String>() {
            {
                put("filePackageName", commonConfigPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("RedisConfig.java", new HashMap<String, String>() {
            {
                put("filePackageName", redisPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("RedisUtils.java", new HashMap<String, String>() {
            {
                put("filePackageName", redisPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });

        fileNames.put("Custom.java", new HashMap<String, String>() {
            {
                put("filePackageName", tokenBeanPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });

        fileNames.put("Token.java", new HashMap<String, String>() {
            {
                put("filePackageName", tokenBeanPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("TokenData.java", new HashMap<String, String>() {
            {
                put("filePackageName", tokenBeanPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("TokenRedis.java", new HashMap<String, String>() {
            {
                put("filePackageName", tokenBeanPackage);
                put("utilsPackage", utilsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("UserToken.java", new HashMap<String, String>() {
            {
                put("filePackageName", tokenBeanPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("TokenConfig.java", new HashMap<String, String>() {
            {
                put("filePackageName", tokenConfigPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });

        fileNames.put("TokenManager.java", new HashMap<String, String>() {
            {
                put("filePackageName", tokenManagerPackage);
                put("enumsPackage", enumsPackage);
                put("exceptionPackage", exceptionPackage);
                put("redisPackage", redisPackage);
                put("tokenBeanPackage", tokenBeanPackage);
                put("tokenConfigPackage", tokenConfigPackage);
                put("utilsPackage", utilsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });

        fileNames.put("DESUtil.java", new HashMap<String, String>() {
            {
                put("filePackageName", utilsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });

        fileNames.put("IpUtil.java", new HashMap<String, String>() {
            {
                put("filePackageName", utilsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("ApiResult.java", new HashMap<String, String>() {
            {
                put("filePackageName", commonBeanPackage);
                put("nowDate", DateUtil.today());
                put("nowDateTime", DateUtil.now());
                put("projectAuthor", projInfo.getAuthor());
                put("enumsPackage", enumsPackage);
                put("commonVoPackage", commonVoPackage);
                put("utilsPackage", utilsPackage);
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("SpringContextUtil.java", new HashMap<String, String>() {
            {
                put("filePackageName", utilsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });

        fileNames.put("LocaleConfig.java", new HashMap<String, String>() {
            {
                put("filePackageName", commonConfigPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("MyLocaleResolver.java", new HashMap<String, String>() {
            {
                put("filePackageName", commonConfigPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("utilsPackage", utilsPackage);
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("MessageUtils.java", new HashMap<String, String>() {
            {
                put("filePackageName", utilsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("enumsPackage", enumsPackage);
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });

        fileNames.put("CommonConfigBean.java", new HashMap<String, String>() {
            {
                put("filePackageName", commonConfigPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("Swagger2Config.java", new HashMap<String, String>() {
            {
                put("filePackageName", serverConfigPath);
                put("controllerPackage", controllerPackage);
                put("projectName", projInfo.getProjectName());
                put("projectAuthor", projInfo.getAuthor());
                put("nowDate", DateUtil.today());
                put("projectSysName", projInfo.getProjectSysName());
                put("utilsPackage", utilsPackage);
                put("projectPort", projInfo.getPort() + "");
                put("authorEmail", projInfo.getAuthorEmail());
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });
        fileNames.put("BeanUtil.java", new HashMap<String, String>() {
            {
                put("filePackageName", utilsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("StringUtil.java", new HashMap<String, String>() {
            {
                put("filePackageName", utilsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("Wrapper.java", new HashMap<String, String>() {
            {
                put("filePackageName", commonBeanPackage);
                put("utilsPackage", utilsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("IdVo.java", new HashMap<String, String>() {
            {
                put("filePackageName", commonVoPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("EmptyVo.java", new HashMap<String, String>() {
            {
                put("filePackageName", commonVoPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("FileInfoVo.java", new HashMap<String, String>() {
            {
                put("filePackageName", commonVoPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });

        fileNames.put("FilePart.java", new HashMap<String, String>() {
            {
                put("filePackageName", commonVoPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });

        fileNames.put("RequestParam.java", new HashMap<String, String>() {
            {
                put("filePackageName", commonVoPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("Base64FileDto.java", new HashMap<String, String>() {
            {
                put("filePackageName", commonDtoPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("BatchSqlInjector.java", new HashMap<String, String>() {
            {
                put("filePackageName", mybatisPlusPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("InsertBatchMethod.java", new HashMap<String, String>() {
            {
                put("filePackageName", mybatisPlusPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("MyBatisPlusConfig.java", new HashMap<String, String>() {
            {
                put("filePackageName", mybatisPlusPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("baseProjectPackage", projInfo.getPackageName());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("RootMapper.java", new HashMap<String, String>() {
            {
                put("filePackageName", mybatisPlusPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("UpdateBatchMethod.java", new HashMap<String, String>() {
            {
                put("filePackageName", mybatisPlusPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("Page.java", new HashMap<String, String>() {
            {
                put("filePackageName", commonBeanPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("EnumCode.java", new HashMap<String, String>() {
            {
                put("filePackageName", enumsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("SubmitAspect.java", new HashMap<String, String>() {
            {
                put("filePackageName", aspectPackage);
                put("annotationPackage", annotationPackage);
                put("enumsPackage", enumsPackage);
                put("exceptionPackage", exceptionPackage);
                put("redisPackage", redisPackage);
                put("utilsPackage", utilsPackage);
                put("nowDate", DateUtil.today());
                put("projectAuthor", projInfo.getAuthor());
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });

        fileNames.put("TemplateApplication.java", new HashMap<String, String>() {
            {
                put("filePackageName", serverBasePackage);
                put("mapperPackage", mapperPackage);
                String fileName = StringUtil.toUpperCaseFirstOne(StringUtil.toUnderscoreToCamelCase(Module.getModule(projInfo).getWebServer()))
                        + "Application";
                put("applicationFileName", fileName);
                put("projectName", projInfo.getProjectName());
                put("baseProjectPackage", projInfo.getPackageName());
                put("projectAuthor", projInfo.getAuthor());
                put("nowDate", DateUtil.today());
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });

        fileNames.put("pom_base.xml", new HashMap<String, String>() {
            {
                put("filePackageName", "pom.xml");
                put("basePackageName", projInfo.getPackageName());
                put("projectName", projInfo.getProjectName());
                put("commonModuleName", Module.getModule(projInfo).getCommon());
                put("serviceModuleName", Module.getModule(projInfo).getService());
                put("webServerModuleName", Module.getModule(projInfo).getWebServer());
                put("projectArtifactId", "${project.artifactId}");
                put("javaVersion", "${java.version}");
                put("moduleName", "");
            }
        });

        fileNames.put("pom_web_server.xml", new HashMap<String, String>() {
            {
                String moduleName = Module.getModule(projInfo).getWebServer();
                String fileName = StringUtil.toUpperCaseFirstOne(StringUtil.toUnderscoreToCamelCase(moduleName)) + "Application";
                put("filePackageName", "pom.xml");
                put("basePackageName", projInfo.getPackageName());
                put("projectName", projInfo.getProjectName());
                put("serverBasePackage", serverBasePackage);
                put("projectSimpleName", projInfo.getProjectSimpleName());
                put("webServerModuleName", Module.getModule(projInfo).getWebServer());
                put("modulePackageName", modulePackage);
                put("serviceModuleName", Module.getModule(projInfo).getService());
                put("applicationClass", fileName);
                put("projectArtifactId", "${project.artifactId}");
                put("javaVersion", "${java.version}");
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });

        fileNames.put("pom_common.xml", new HashMap<String, String>() {
            {
                put("filePackageName", "pom.xml");
                put("basePackageName", projInfo.getPackageName());
                put("projectName", projInfo.getProjectName());
                put("commonModuleName", Module.getModule(projInfo).getCommon());
                put("commonPackageName", commonPackage);
                put("projectArtifactId", "${project.artifactId}");
                put("javaVersion", "${java.version}");
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });

        fileNames.put("pom_service.xml", new HashMap<String, String>() {
            {
                put("filePackageName", "pom.xml");
                put("basePackageName", projInfo.getPackageName());
                put("projectName", projInfo.getProjectName());
                put("serviceModuleName", Module.getModule(projInfo).getService());
                put("modulePackageName", modulePackage);
                put("commonModuleName", Module.getModule(projInfo).getCommon());
                put("commonPackageName", commonPackage);
                put("projectArtifactId", "${project.artifactId}");
                put("javaVersion", "${java.version}");
                put("moduleName", Module.getModule(projInfo).getService());
            }
        });

        fileNames.put("logback.xml", new HashMap<String, String>() {
            {
                put("filePackageName", "logback.xml");
                put("projectName", projInfo.getProjectName());
                put("webServerModuleName", Module.getModule(projInfo).getWebServer());
                put("nowDate", DateUtil.today());
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });
        fileNames.put(".gitignore", new HashMap<String, String>() {
            {
                put("filePackageName", ".gitignore");
            }
        });

        fileNames.put("application.yml", new HashMap<String, String>() {
            {
                put("filePackageName", "application.yml");
                put("moduleName", Module.getModule(projInfo).getWebServer());
            }
        });

        fileNames.put("application-test.yml", new HashMap<String, String>() {
            {
                put("filePackageName", "application-test.yml");
                put("projectName", projInfo.getProjectName());
                put("projectPort", String.valueOf(projInfo.getPort()));
                put("projectSimpleName", projInfo.getProjectSimpleName());
                put("basePackage", projInfo.getPackageName());
                put("moduleName", Module.getModule(projInfo).getWebServer());
                put("entityPackage", entityPackage);
                put("mappingsPath", mappingPath);
                put("dbUrl", connector.getUrl());
                put("dbUsername", connector.getUser());
                put("dbPassword", connector.getPassword());
                put("dbDriver", connector.getDriver());
                put("baseProjectPackage", projInfo.getPackageName());
                put("webServerModuleName", Module.getModule(projInfo).getWebServer());
                put("firstBasePackage", projInfo.getPackageName().split("\\.")[0]);
                put("secondBasePackage", projInfo.getPackageName().split("\\.")[1]);
                put("authorEmail", projInfo.getAuthorEmail());
                put("baseProjectPackagePath", projInfo.getPackageName().replaceAll("\\.", "/"));
            }
        });

        fileNames.put("application-prod.yml", new HashMap<String, String>() {
            {
                put("filePackageName", "application-prod.yml");
                put("projectName", projInfo.getProjectName());
                put("projectPort", String.valueOf(projInfo.getPort()));
                put("projectSimpleName", projInfo.getProjectSimpleName());
                put("moduleName", Module.getModule(projInfo).getWebServer());
                put("entityPackage", entityPackage);
                put("mappingsPath", mappingPath);
                put("dbUrl", connector.getUrl());
                put("dbUsername", connector.getUser());
                put("dbPassword", connector.getPassword());
                put("dbDriver", connector.getDriver());
                put("baseProjectPackage", projInfo.getPackageName());
                put("webServerModuleName", Module.getModule(projInfo).getWebServer());
                put("firstBasePackage", projInfo.getPackageName().split("\\.")[0]);
                put("secondBasePackage", projInfo.getPackageName().split("\\.")[1]);
                put("authorEmail", projInfo.getAuthorEmail());
                put("baseProjectPackagePath", projInfo.getPackageName().replaceAll("\\.", "/"));
            }
        });

        fileNames.put("messages.properties", new HashMap<String, String>() {
            {
                put("filePackageName", "static\\i18n\\messages.properties");
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("messages_en_US.properties", new HashMap<String, String>() {
            {
                put("filePackageName", "static\\i18n\\messages_en_US.properties");
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });
        fileNames.put("messages_zh_CN.properties", new HashMap<String, String>() {
            {
                put("filePackageName", "static\\i18n\\messages_zh_CN.properties");
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });

        fileNames.put("EntityData.java", new HashMap<String, String>() {
            {
                put("filePackageName", commonBeanPackage);
                put("projectAuthor", projInfo.getAuthor());
                put("nowDate", DateUtil.today());
                put("moduleName", Module.getModule(projInfo).getCommon());
            }
        });

        if (projInfo.isThymeleaf()) {
            fileNames.put("IndexViewController.java", new HashMap<String, String>() {
                {
                    put("filePackageName", viewControllerPackage);
                    put("projectSysName", projInfo.getProjectSysName());
                    put("utilsPackage", utilsPackage);
                    put("projectAuthor", projInfo.getAuthor());
                    put("nowDate", DateUtil.today());
                    put("moduleName", Module.getModule(projInfo).getWebServer());
                }
            });

            fileNames.put("index.html", new HashMap<String, String>() {
                {
                    put("filePackageName", "index.html");
                    put("moduleName", Module.getModule(projInfo).getWebServer());
                }
            });

            fileNames.put("login.html", new HashMap<String, String>() {
                {
                    put("filePackageName", "login.html");
                    put("moduleName", Module.getModule(projInfo).getWebServer());
                }
            });

            fileNames.put("template_nav.js", new HashMap<String, String>() {
                {
                    put("filePackageName", "js\\nav.js");
                    put("moduleName", Module.getModule(projInfo).getWebServer());
                }
            });
        }

        return fileNames;
    }
}
